@extends('home.lei.business.index')
@section('r_content')
	<div style="width:950px;height:450px;float:left;background:white;margin-left:10px;">
		<div style="width:900px;height:40px;background:#ccc;margin-top:10px;">
			<span style="font-size:30px;color:white;">菜品列表</span>
		</div>
		<div style="width:880px;height:400px;background:;margin-top:10px;">
			<table widtd="870px" class="table table-bordered">
				<tr align="center">
					<td><b>ID</b></td>
					<td><b>名称</b></td>
					<td><b>价格</b></td>
					<td><b>描述</b></td>
					<td><b>操作</b></td>
				</tr>
					@foreach($data as $k=>$v)
						<tr align="center">
							<td>{{$v['id']}}</td>
							<td>{{$v['g_name']}}</td>
							<td>{{$v['g_price']}}</td>
							<td>{{$v['g_description']}}</td>
							<td>
								<a href="/home/good/{{$v['id']}}/edit">修改</a>
								<a href="javascript:void(0)" onclick="fun({{$v['id']}})">删除</a>
							</td>
						</tr>
					@endforeach
			</table>
			<div style="float:right">
				{!! $data->render() !!}
			</div>
		</div>
	</div>
	<script type="text/javascript">
		function fun(id){
		layer.confirm('是否确认删除？', {
                btn: ['确认','取消'] //按钮
            }, function(){
                $.post('{{url('home/good/')}}/'+id,{'_token':'{{csrf_token()}}','_method':'delete'},function(data){
                    //console.log(data);
	                //删除成功
                    if(data.status == 0){
                        layer.msg(data.msg, {icon: 6});
                        location.href = location.href;
                    }else{
                        layer.msg(data.msg, {icon: 5});
                        location.href = location.href;
                    }
                });

            }, function(){

            });

	}
	</script>
@endsection